<template>
	<view class="container">
		<view class="main">
			<view class="password">原密码:<input type="text" value="" @input="password" v-model="passwords" placeholder="请输入原密码" /><image src="../../../static/images/yan.png" mode=""></image></view>
			<view class="password">新密码:<input type="text" @input="newPassword" displayable v-model="newPasswords" value="" placeholder="请输入新密码" /><image src="../../../static/images/yan1.png" mode="" style="width: 34rpx;height: 28rpx;"></image></view>
			<view class="password">确认新密码:<input type="text" displayable v-model="newPasswordsy" displayable value="" placeholder="请再次输入新密码" /><image src="../../../static/images/yan1.png" mode="" style="width: 34rpx;height: 28rpx;"></image></view>
		</view>
		<button type="default" @click="xiu">确定</button>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				// name:'',
				// password:''
			}
		},
		methods:{
			xiu() {
				if(this.newPasswordsy!==this.newPasswords){
					uni.showToast({
						title:'密码输入不正确'
					})
				}
				},
			newPassword:function(e){
				this.newPasswords=e.target.value
			},
			password:function(e){
				this.passwords=e.target.value
			},
			xiu(){
				uni.request({
				     url: this.$url + 'system/user/profile/updatePwd',
					 header:{
					  'Authorization': 'Bearer ' + uni.getStorageSync("token"),
					  'content-type':'application/x-www-form-urlencoded'
					 },
				     method: 'PUT',
					 data:{
						 oldPassword: this.passwords,
						 newPassword: this.newPasswords,
					 },
				     success: (res) => {
				        console.log(res);
						if(res.data.code==200){
							console.log(res.data.data,111)
							uni.setStorageSync("token", res.data.data);
							uni.reLaunch({
								url:'../index/index'
							})
						}
				     },
				     complete: () => {
				      
				     },
				     fail: (e) => {
				      console.log(e);
				     }
				    });
			},
		}
	}
</script>

<style lang="scss">
page{
	.container{
		.main{
			// border: 1px solid #ff0;
			margin:0rpx 30rpx;
			font-size: 30rpx;
			.password{
				display: flex;
				justify-content:space-between;
				align-items: center;
				line-height: 90rpx;
				border-bottom: 1px solid #FFF2F2F2;
				image{
					width: 34rpx;
					height: 21rpx;
				}
				input{
					font-size:26rpx !important;
				}
			}
		}
		button{
			width: 690rpx;
			height: 98rpx;
			background: #3472FD;
			border-radius: 44rpx;
			font-size: 36rpx;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 98rpx;
			text-align: center;
			margin-top: 60rpx;
		}
	}
}	
</style>
